//Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections.Generic;
using System.Text;

namespace Eas.WebCrawler.Interfaces {
    /// <summary>Stores <see cref="Request"/>s which are intended to be processed by the crawler.</summary>
    public interface RequestStore : WebCrawlerComponent{

        /// <summary>Forces an add of this request into the queue, regardless of if it is a duplicate or not.</summary>
        /// <param name="request">The request to add.</param>
        void AddPriorityRequest(Request request);

        /// <summary>Adds a <see cref="Request"/> to the store.</summary>
        /// <param name="uri">The uri of the request to add.</param>
        /// <param name="parent">The parent of the current request (the page on which the link is found) or <code>null</code> if this request has not parent.</param>
        /// <returns><code>true</code> if the request was added, otherwise false.</returns>
        bool AddRequest(string uri, Request parent);

        /// <summary>Adds a <see cref="Request"/> to the store.</summary>
        /// <param name="uri">The uri of the request to add.</param>
        /// <param name="parent">The parent of the current request (the page on which the link is found) or <code>null</code> if this request has not parent.</param>
        /// <returns><code>true</code> if the request was added, otherwise false.</returns>
        bool AddRequest(Uri uri, Request parent);

        /// <summary>Adds a <see cref="Request"/> to the store.</summary>
        /// <param name="request">The <see cref="Request"/> to add.</param>
        /// <returns><code>true</code> if the request was added, otherwise false.</returns>
        bool AddRequest(Request request);

        /// <summary>Adds a range of requests.</summary>
        /// <param name="requests">The requests to add.</param>
        void AddRange(IEnumerable<string> requests);

        /// <summary>Removes the next <see cref="Request"/> from the store.</summary>
        /// <returns>The next <see cref="Request"/> from the store, or <code>null</code> if the store is empty.</returns>
        Request PopRequest();

        /// <summary>The number of <see cref="Request"/>s in the store.</summary>
        int Count {
            get;
        }

        /// <summary>Whether or not the store has any <see cref="Request"/>s in it.</summary>
        bool HasRequests {
            get;
        }
    }
}
